<?php

namespace App\Models\Article;

use App\Models\BaseModel;
use App\Models\Traits\KfSoftDeletes;
use App\Models\Traits\KfUid;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;

class ArticleCategoryModel extends BaseModel
{
    use HasFactory, KfUid, KfSoftDeletes;

    protected $fillable = [
        'id',
        'name',
        'description',
        'cover',
        'type',
        'createdAt',
        'createdByUid',
        'updatedAt',
        'updatedByUid',
        'isDeleted',
    ];

    protected $table = "article_category";

    public $timestamps = false;

    const TYPE_NORMAL  = 0;
    const TYPE_SUBJECT = 1;
    const TYPE_TEXT    = [
        self::TYPE_NORMAL  => "普通分类",
        self::TYPE_SUBJECT => "专题分类",
    ];

    const PUT_TOP_YES  = 1;
    const PUT_TOP_NO   = 0;
    const PUT_TOP_TEXT = [
        self::PUT_TOP_NO  => "常规",
        self::PUT_TOP_YES => "置顶",
    ];

    /**
     * @return HasMany
     */
    public function articleCategoryMappingsRel(): HasMany
    {
        return $this->hasMany(ArticleCategoryMappingsModel::class, "categoryId", "id");
    }
}
